package mathematics.geometry;

import java.util.ArrayList;
import utils.Point3D;
import utils.Vector3D;

public class DiskGeometry extends Geometry
{
	/**
	 * 
	 */
	private static final long serialVersionUID = -5711541832564581935L;
	private static short slices = 64;
	private Point3D center;
	public float radius;
	
	public DiskGeometry(ArrayList<Point3D> outline)
	{
		super(outline);
		this.center = super.getCentroid();
		Vector3D v = new Vector3D(this.center, outline.get(0));
		this.radius = (float) v.length();
	}
	
	public DiskGeometry(Point3D center, float radius)
	{
		this.center = center;
		this.radius = radius;
		
		float angle = (float) (Math.PI * 2 / slices);
		
	    for(short i = 0; i < slices + 1; ++i )
		{    
		    float x = (float) (center.x() + Math.cos(angle * i) * radius);
		    float y = (float) (center.y() + Math.sin(angle * i) * radius);
		    
		    this.add(new Point3D(x,y,0));
		}
	}
	
	@Override
	public Point3D getCentroid()
	{
		return this.center;
	}
}